import { useUserStoreHook } from "@/store/user";
import uma from '@/plugins/umtrack-wx';
import { formatTime } from "@/utils/index";
const loginData = useUserStoreHook()
//数字前加0
export function paramJson() {
	return {
		'userID': "+" + loginData.userId, 'staffName': loginData.user.staffName, 'organID': "+" + loginData.organId, 'organName': loginData.organ.organName
		, 'eventTime': formatTime(new Date().getTime(), "yyyy-MM-dd hh:mm:ss") + "==" + loginData.userId
	};
}

//友盟埋点方法
//um_event_viewGoodsLocation_index:收货台_收货清单
//um_event_viewGoodsLocation_location:收货台_查看位置

export function addUmaMd(key : string) {
	if (!loginData.accessToken) {
		return;
	}
	let param = paramJson();
	console.log("==================umaParam=" + key + "==" + JSON.stringify(param));
	uma.trackEvent(key, param);
}